home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / src / softkeys.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-15  |  5.9 KB  |  188 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: softkeys.c,v 5.2 1993/04/16 03:51:38 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  6.  *
  7.  *            Copyright (c) 1988-1992 USENET Community Trust
  8.  *            Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: softkeys.c,v $
  17.  * Revision 5.2  1993/04/16  03:51:38  syd
  18.  * I found a small screen corruption problem with elm.  If you select 'c' for
  19.  * change mailbox and then back out by just typing <Return> at the prompt for the
  20.  * new mailbox, the prompt 'Command: ' seems to be reprinted on the wrong line
  21.  * leaving the previous prompt and the 'Change Mailbox' string in place.
  22.  *
  23.  * Further investiagtion tracked the problem to the softkey programming.  When a
  24.  * newline (LF) character is sent to the terminal in the sofkey's "send" string,
  25.  * the terminal still performs a linefeed just as if the linefeed were sent at any
  26.  * other time.  The particlar set of softkeys for change mode has four such
  27.  * newlines and this is enought to cause the screen to scroll up one line.  This
  28.  * in turn causes the prompt to appear on the wrong line.
  29.  *
  30.  * I have fixed this by replacing the newlines with carriage returns instead.  I
  31.  * checked and this still performs the desired action without actually scrolling
  32.  * the screen.
  33.  * From: Steve Fosdick <stevef@aom.bt.co.uk>
  34.  *
  35.  * Revision 5.1  1992/10/03  22:58:40  syd
  36.  * Initial checkin as of 2.4 Release at PL0
  37.  *
  38.  *
  39.  *******************************************************************************
  40.  */
  41.  
  42. #include "headers.h"
  43. #include "s_elm.h"
  44.  
  45. define_softkeys(level)
  46. int level;
  47. {
  48.     if (! hp_softkeys) return;
  49.  
  50.     if (level == MAIN) {
  51.  
  52.       define_key(f_key1, catgets(elm_msg_cat, ElmSet, ElmKeyF1,
  53.         " Display   Msg"),   "\r");
  54.       define_key(f_key2, catgets(elm_msg_cat, ElmSet, ElmKeyF2,
  55.         "  Mail     Msg"),   "m");
  56.       define_key(f_key3, catgets(elm_msg_cat, ElmSet, ElmKeyF3,
  57.         "  Reply  to Msg"),  "r");
  58.  
  59.       if (user_level == 0) {
  60.         define_key(f_key4, catgets(elm_msg_cat, ElmSet, ElmKey0F4,
  61.         "  Save     Msg"),   "s");
  62.         define_key(f_key5, catgets(elm_msg_cat, ElmSet, ElmKey0F5
  63.         ," Delete    Msg"),   "d");
  64.         define_key(f_key6, catgets(elm_msg_cat, ElmSet, ElmKey0F6,
  65.         "Undelete   Msg"),   "u");
  66.          }
  67.       else {
  68.         define_key(f_key4, catgets(elm_msg_cat, ElmSet, ElmKey1F4,
  69.         " Change  Folder"), "c");
  70.         define_key(f_key5, catgets(elm_msg_cat, ElmSet, ElmKey1F5,
  71.         "  Save     Msg"),   "s");
  72.         define_key(f_key6, catgets(elm_msg_cat, ElmSet, ElmKey1F6,
  73.         " Delete/Undelete"), "^");
  74.       }
  75.  
  76.       define_key(f_key7, catgets(elm_msg_cat, ElmSet, ElmKeyF7,
  77.         " Print     Msg"),   "p");
  78.       define_key(f_key8, catgets(elm_msg_cat, ElmSet, ElmKeyF8,
  79.         "  Quit     ELM"),   "q");
  80.     }
  81.     else if (level == ALIAS) {
  82.       define_key(f_key1, catgets(elm_msg_cat, ElmSet, ElmKeyAF1,
  83.         " Alias  Current"),  "a");
  84.       define_key(f_key2, catgets(elm_msg_cat, ElmSet, ElmKeyAF2,
  85.         " Check  Person"),   "p");
  86.       define_key(f_key3, catgets(elm_msg_cat, ElmSet, ElmKeyAF3,
  87.         " Check  System"),   "s");
  88.       define_key(f_key4, catgets(elm_msg_cat, ElmSet, ElmKeyAF4,
  89.         " Make    Alias"),   "m");
  90.       clear_key(f_key5);
  91.       clear_key(f_key6);
  92.       clear_key(f_key7);
  93.       define_key(f_key8, catgets(elm_msg_cat, ElmSet, ElmKeyAF8,
  94.         " Return  to ELM"),  "r");
  95.     }
  96.     else if (level == YESNO) {
  97.       define_key(f_key1, catgets(elm_msg_cat, ElmSet, ElmKeyYF1,
  98.         "  Yes"),  "y");
  99.       clear_key(f_key2);
  100.       clear_key(f_key3);
  101.       clear_key(f_key4);
  102.       clear_key(f_key5);
  103.       clear_key(f_key6);
  104.       clear_key(f_key7);
  105.       define_key(f_key8, catgets(elm_msg_cat, ElmSet, ElmKeyYF8,
  106.         "   No"),  "n");
  107.     }
  108.     else if (level == READ) {
  109.       define_key(f_key1, catgets(elm_msg_cat, ElmSet, ElmKeyRF1,
  110.         "  Next    Page  "), " ");
  111.       clear_key(f_key2);
  112.       define_key(f_key3, catgets(elm_msg_cat, ElmSet, ElmKeyRF3,
  113.         "  Next    Msg   "), "j");
  114.       define_key(f_key4, catgets(elm_msg_cat, ElmSet, ElmKeyRF4,
  115.         "  Prev    Msg   "), "k");
  116.       define_key(f_key5, catgets(elm_msg_cat, ElmSet, ElmKeyRF5,
  117.         "  Reply  to Msg "), "r");
  118.       define_key(f_key6, catgets(elm_msg_cat, ElmSet, ElmKeyRF6,
  119.         " Delete   Msg   "), "d");
  120.       define_key(f_key7, catgets(elm_msg_cat, ElmSet, ElmKeyRF7,
  121.         "  Send    Msg   "), "m");
  122.       define_key(f_key8, catgets(elm_msg_cat, ElmSet, ElmKeyRF8,
  123.         " Return  to ELM "), "q");
  124.     }
  125.     else if (level == CHANGE) {
  126.       define_key(f_key1, catgets(elm_msg_cat, ElmSet, ElmKeyCF1,
  127.         "  Mail  Directry"), "=/");
  128.       define_key(f_key2, catgets(elm_msg_cat, ElmSet, ElmKeyCF2,
  129.         "  Home  Directry"), "~/");
  130.       clear_key(f_key3);
  131.       define_key(f_key4, catgets(elm_msg_cat, ElmSet, ElmKeyCF4,
  132.         "Incoming Mailbox"), "!\r");
  133.       define_key(f_key5, catgets(elm_msg_cat, ElmSet, ElmKeyCF5,
  134.         "\"Received\" Folder"), ">\r");
  135.       define_key(f_key6, catgets(elm_msg_cat, ElmSet, ElmKeyCF6,
  136.         "\"Sent\"   Folder "), "<\r");
  137.       clear_key(f_key7);
  138.       define_key(f_key8, catgets(elm_msg_cat, ElmSet, ElmKeyCF8,
  139.         " Cancel"), "\n");
  140.     }
  141.  
  142.     softkeys_on();
  143. }
  144.  
  145. define_key(key, display, send)
  146. int key;
  147. char *display, *send;
  148. {
  149.  
  150.     char buffer[30];
  151.  
  152.     sprintf(buffer,"%s%s", display, send);
  153.  
  154.     fprintf(stderr, "%c&f%dk%dd%dL%s", ESCAPE, key,
  155.         strlen(display), strlen(send), buffer);
  156.     fflush(stdout);
  157. }
  158.  
  159. softkeys_on()    
  160.     /* enable (esc&s1A) turn on softkeys (esc&jB) and turn on MENU 
  161.        and USER/SYSTEM options. */
  162.  
  163.     if (hp_softkeys) {
  164.       fprintf(stderr, "%c&s1A%c&jB%c&jR", ESCAPE, ESCAPE, ESCAPE); 
  165.       fflush(stdout);
  166.     }
  167.     
  168. }
  169.  
  170. softkeys_off()    
  171.     /* turn off softkeys (esc&j@) */
  172.  
  173.     if (hp_softkeys) {
  174.       fprintf(stderr, "%c&s0A%c&j@", ESCAPE, ESCAPE); 
  175.       fflush(stdout);
  176.     }
  177. }
  178.  
  179. clear_key(key)  
  180. {     
  181.     /** set a key to nothing... **/
  182.  
  183.     if (hp_softkeys) 
  184.        define_key(key, "                ", ""); 
  185. }
  186.